package routes

import (
	"gitee.com/DonHz/qimi/bluebell/controller"
	"gitee.com/DonHz/qimi/bluebell/util/logger"
	"gitee.com/DonHz/qimi/bluebell/util/middleware"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Setup() *gin.Engine {
	r:=gin.New()
	r.Use(logger.GinLogger(), logger.GinRecovery(true))

	v1:=r.Group("/api/v1")

	v1.GET("/hello", func(ctx *gin.Context) {
		ctx.String(http.StatusOK, "Hello! Boy!")
	})
	v1.POST("/signup", controller.SignUp)
	v1.POST("/login", controller.Login)
	v1.Use(middleware.JWTAuthMiddleware())
	{
		v1.GET("/community", controller.CommunityHandler)
		v1.GET("/community/:id", controller.CommunityDetailHandler)

		v1.POST("/article", controller.CreatePostHandler)
		v1.GET("/article/:id", controller.ArticleDetailHandler)
		v1.GET("/articles", controller.GetArticleListHandler)

		v1.POST("/vote", controller.PostVoteController)


	}

	return r
}